Scripting Help

Category: Geeks r Us

Post 1 by BethanyRose (the one and only Rose of Nativeness) on Tuesday, 09-Feb-2010 7:08:44

Hi All:

Rosie needs a little help with some scripting for her website. I have an alert for younger site visitors, that looks like this:
<html> <HEAD>

<SCRIPT LANGUAGE="JavaScript">


<!-- Begin
function getName() {
var name1 = prompt("What is your name?", "")
var age = prompt("How old are you?", "")
if( age <= 12) {
alert("Sorry, little one...You're only " + age + " and can't come in now!" + name1 + ", but there is a place here just for you!")
window.open("http://www.crimsonsoul.net/ssl/playground.html")
} else {
alert("Hello " + name1 + "! Welcome to Crimson Soul! Since you are " + age + ", you can proceed!!!")
}
}
// End -->
</SCRIPT>



<BODY onLoad="getName()">

</html>

The thing is, I don't want older repeat visitors to have to complete this age check every time they access the pages where this script in implemented. Is there a way I can ensure that they don't have to do this?

Thanks!

NativeRose

Post 2 by blindndangerous (the blind and dangerous one) on Tuesday, 09-Feb-2010 15:28:20

Is their some way that you could have it log the users external IP? I have no idea if this is even possible, since I don't know a thing about javascript, but that's the idea that I have. Granted, they would have to enter the page again if their external IP changed, but that could be a temporary solution.

Post 3 by TylerK (This site is so "educational") on Tuesday, 09-Feb-2010 15:50:18

I've heard of persistence by using cookies from JavaScript, but I don't know how that would work...I know it can be done, though. Oh, and by the way, you forgot to close your <body> tag...and also, it's common practice to end your JavaScript statements with semicolons, like this:

var name1=prompt("What is your name?", "");

Post 4 by BethanyRose (the one and only Rose of Nativeness) on Wednesday, 10-Feb-2010 12:23:58

oh lol, did I forget to end it with a semicolon? silly me! I always wondered why they call them cookies anyway. I mean, cookies are supposed to be eaten, not used to store a computer user's information. Just a random thought...